    <layout name="Layout/main"/>
    <?php if(!empty($ency) && is_array($ency)){?>
        <form id="post_form" action="__APP__/admin/pet/ency_edit" method="post" enctype="multipart/form-data">
    <?php }else{ ?>
        <form id="post_form" action="__APP__/admin/pet/addPet" method="post" enctype="multipart/form-data">
    <?php } ?>
        <input name="submit" value="OK" type="hidden"/>
        <input name="id" value="<?php echo $ency['id']?>" type="hidden"/>
    <div class="content_ency">
        <dl>
            <dt>宠物名称：</dt>
            <dd><input name="name" type="text" class="text_200" value="<?php echo $ency['name']?>">
            <span class="error"></span>
            </dd>
        </dl>
        <dl>
            <dt>宠物种类：</dt>
            <dd><select name='category'>
                    <?php foreach($cate_list as $k => $v){?>
                    <option value="<?php echo $v['id']?>" <?php if($v['id'] == $ency['category']){?>selected<?php }?>><?php echo $v['name']?></option>
                    <?php } ?>
                </select>
            </dd>
        </dl>
        <dl>
            <dt>宠物英文名：</dt>
            <dd><input name="foreginname" type="text" class="text_200" value="<?php echo $ency['foreignname']?>">
                <span class="error"></span>
            </dd>
        </dl>
        <dl>
            <dt>宠物别名：</dt>
            <dd><input name="othername" type="text" class="text_200" value="<?php echo $ency['othername']?>">
                <span class="error"></span>
            </dd>
        </dl>
        <dl>
            <dt>宠物图片：</dt>
            <dd><img id="pet_photo" src="__PUBLIC__/function/upload/<?php echo $ency['photo']?>"><br/>
                <input type="file" name="photo" style="margin-left: 200px; "/>
                <input type="hidden" name="pet_photo" value="<?php echo $ency['photo']?>"/>
                <span class="error"></span>
            </dd>
        </dl>
        <dl>
            <dt>宠物产地：</dt>
            <dd><input name="chandi" type="text" class="text_200" value="<?php echo $ency['chandi']?>">
                <span class="error"></span>
            </dd>
        </dl>
        <dl>
            <dt>宠物寿命：</dt>
            <dd><input name="shouming" type="text" class="text_200" value="<?php echo $ency['shouming']?>"><em class="add-on">年</em>
                <span class="error"></span>
            </dd>
        </dl>
        <dl>
            <dt>宠物毛色：</dt>
            <dd><select name='haircolor'>
                    <?php foreach($color_list as $k => $v){?>
                        <option value="<?php echo $v['id']?>" <?php if($v['id'] == $ency['haircolor']){?>selected<?php }?>><?php echo $v['name']?></option>
                    <?php } ?>
                </select>
            </dd>
        </dl>
        <dl>
            <dt>宠物特性：</dt>
            <dd><select name='feature'>
                    <?php foreach($feature_list as $k => $v){?>
                        <option value="<?php echo $v['id']?>" <?php if($v['id'] == $ency['feature']){?>selected<?php }?>><?php echo $v['name']?></option>
                    <?php } ?>
                </select>
            </dd>
        </dl>
        <dl>
            <dt>宠物介绍：</dt>
            <dd><?php showEditor('introduce',$ency['introduce'],'100px','250px','visibility:hidden;',"false")?></dd>
        </dl>
        <dl>
            <input type="submit" style="margin:5% 20%" value="提交"/>
        </dl>
    </div>
</form>
<script>
$(function(){
    $("input[name='photo']").change(function(){
        var src = getFullPath($(this)[0]);
        $("input[name='pet_photo']").val(src);
        $("#pet_photo").attr('src',src);
    });
    $("#post_form").validate({
        errorPlacement: function(error, element) {
            error.appendTo(element.nextAll('span'));
        },
        rules:{
            name : {
                required : true
            },
            foreginname:{
                required : true
            },
            othername:{
                required : true
            },
            pet_photo:{
                required : true
            },
            chandi:{
                required : true
            },
            shouming:{
                required : true,
                number   : true,
                min      : 0
            }
        },
        messages:{
            name : {
                required : '请输入宠物名称'
            },
            foreginname : {
                required : '请输入宠物英文名称'
            },
            othername : {
                required : '请输入宠物别名'
            },
            pet_photo : {
                required : '请上传宠物图片'
            },
            chandi : {
                required : '请填写宠物产地'
            },
            shouming : {
                required : '请填写宠物寿命',
                number   : '请填写大于0的数字',
                min      : '请填写大于0的数字'
            }
        }
    });
});
</script>